import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { STColumn, STPage, STColumnTag } from '@delon/abc/table';
import { SFSchema, SFComponent, SFRadioWidgetSchema } from '@delon/form';
import { HttpService, SupDic, GridComponent } from 'lbf';
import { NzMessageService, NzModalService } from 'ng-zorro-antd';
import { LbStepsComponent } from '@shared/components/lb-steps/lb-steps.component';
import { LbWjfwComponent } from '@shared/components/lb_wjfw/lbwjfw.component';
import { LbRepComponent } from '@shared/components/lb-rep/lb-rep.component';

@Component({
  selector: 'app-bbtj-bjltj',
  templateUrl: './bjltj.component.html',
})
export class BbtjBjltjComponent implements OnInit {
  tabMode = '';
  isVisible = false;

  constructor(
    private supdic: SupDic,
    private lbservice: HttpService,
    public msgSrv: NzMessageService,
    private modalService: NzModalService,
  ) {}
  @ViewChild('sf', { static: false }) sf: SFComponent;
  @ViewChild('st', { static: true }) st: GridComponent;
  params = {
    sname: 'BJTJ_BJLTJ',
    form: {},
  };
  TAG: STColumnTag = {
    0: { text: '不通过', color: 'red' },
    1: { text: '通过', color: 'green' },
  };

  searchSchema: SFSchema = {
    properties: {
      AAA027: {
        type: 'string',
        title: '统筹区',
        enum: this.supdic.getSFDic('AAA027'),
        ui: {
          widget: 'select',
          allowClear: true,
          grid: { span: 6 },
        },
      },
      SDATE: {
        type: 'string',
        title: '开始时间起',
        ui: { widget: 'date' },
      },
      EDATE: {
        type: 'string',
        title: '开始时间止',
        ui: { widget: 'date' },
      },
      DAD024: {
        type: 'string',
        title: '环节名称',
        enum: this.supdic.getSFDic('DAD024'),
        ui: { widget: 'select', allowClear: true, grid: { span: 6 } },
      },
      DAD017: {
        type: 'string',
        title: '主事项名称',
        enum: this.supdic.getSFDic('DAD017'),
        ui: {
          widget: 'select',
          allowClear: true,
        },
      },
      AAB004: {
        type: 'string',
        title: '单位名称',
      },
    },
    ui: {
      spanLabelFixed: 100,
      grid: {
        span: 8,
      },
    },
  };
  columns: STColumn[] = [
    {
      title: '主事项名称',
      index: 'DAD017',
      dic: 'DAD017',
      width: '100px',
      fixed: 'left',
    },
    { title: '环节', index: 'DAD024', dic: 'DAD024' },
    { title: '环节状态', index: 'DAD095', type: 'tag', tag: this.TAG },
    { title: '统筹区', index: 'AAA027', dic: 'AAA027' },
    { title: '社会保障号', index: 'AAC002' },
    { title: '姓名', index: 'AAC003' },
    { title: '性别', index: 'AAC004', dic: 'AAC004' },
    { title: '单位编码', index: 'AAB001' },
    { title: '单位名称', index: 'AAB004' },
    { title: '胎儿数', index: 'AMC028' },
    { title: '津贴基数', index: 'AMC011' },
    { title: '生育类别', index: 'AAC004', dic: 'AMC002' },
    { title: '产假天数', index: 'AMC032' },
    { title: '生育时间', index: 'AMC020' },
    { title: '医疗机构名称', index: 'AKB021' },
    { title: '医疗机构类型', index: 'AKC201', dic: 'AKC201' },
    { title: '开始年月', index: 'AAE310' },
    { title: '结束年月', index: 'AAE311' },
    { title: '待遇金额', index: 'AAE019' },
    { title: '不予受理原因', index: 'DAD098' },
    { title: '开始时间', index: 'DAD096' },
    { title: '结束时间', index: 'DAD097' },
  ];
  page: STPage = {
    show: false,
  };
  ngOnInit() {}

  _onReuseInit(): void {
    this.query();
  }
  query() {
    this.st.reload(this.sf.value);
  }
  selectTab() {
    this.tabMode = 'show';
  }
  handleCancel() {
    this.tabMode = '';
    this.isVisible = false;
  }
  reset() {
    this.sf.formData = null;
    this.sf.reset();
  }
}
